<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>寻找丢失的数字</title>
</head>

<body>
  <script>
    let arr = [1, 2, 3, 4, 5, 6, 7, 9, 0]
    let sum = 0
    aar = arr.length
    for (let i = 0; i < aar; i++) {
      sum += arr[i]

    }
    //1+9是10/4.5=45也就是0-9的总数-sum(是上面那个数组)===少的那个
    console.log((1 + aar) * (aar / 2) - sum)
    console.log(sum)

  </script>
</body>

</html>